package com.ftg.learn.bus.sharecar_expendrecord.controllre;


import com.ftg.learn.bus.sharecar_expendrecord.pojo.sharecar_expendrecord_admin;
import com.ftg.learn.bus.sharecar_expendrecord.service.Sharecar_Expendrecord_Admin_Service;
import com.ftg.learn.bus.sharecar_userecord.pojo.sharecar_userecord_admin;
import com.ftg.learn.bus.util.ResultType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@Api(value = "公车经费支出登记",tags = "公车经费支出登记")
public class Sharecar_Expendrecord_Admin_Controllre {
    @Autowired
    Sharecar_Expendrecord_Admin_Service auas;

    @GetMapping("/sharecarexpendrecord/query")
    @ApiOperation("查询全部")
    public List<sharecar_expendrecord_admin> query(){
        return auas.query();
    }


    @PutMapping("/sharecarexpendrecord/queryone/{id}")
    @ApiOperation(value = "查一条")
    public sharecar_expendrecord_admin queryOne(@ApiParam("d汽车id") @PathVariable String id){
        return auas.queryOne(id);
    }

    @PostMapping("/sharecarexpendrecord/insert")
    @ApiOperation(value = "添加")
    public int insert(sharecar_expendrecord_admin sua){
        return auas.insert(sua);
    }

    @ApiOperation(value = "修改")
    @PostMapping("/sharecarexpendrecord/update")
    public int update(sharecar_expendrecord_admin sua, String expendcar_id){
        return auas.update(sua,expendcar_id);
    }

    @GetMapping("/sharecarexpendrecord/querybylimit/{page}&{limit}&{usecar_id}&{principal}")
    @ApiOperation("查询全部+模糊查询+分页")
    public ResultType<sharecar_expendrecord_admin> query(@ApiParam("页数") @PathVariable int page, @ApiParam("每页条目数") @PathVariable int limit, @ApiParam("id的模糊") @PathVariable String usecar_id, @ApiParam("负责人") @PathVariable String principal){
        return auas.query(page, limit,usecar_id,principal);
    }

    @PutMapping("/sharecarexpendrecord/delete")
    @ApiOperation(value = "删除")
    public int delete( String id){
        return auas.delete(id);
    }

    @GetMapping("/sharecar/costable")
    @ApiOperation("费用统计")
    public List<Map<String,Object>> costTable(){
        return auas.costTable();
    }

    @GetMapping("/sharecarinvoice/{car_id}")
    @ApiOperation("开具发票")
    public List<Map<String,Object>> invoice(@ApiParam("车牌号") @PathVariable String car_id){
        return auas.invoice(car_id);
    }

    @PutMapping("/sharecarexpendrecord/toExcel/{url}")
    @ApiOperation("导出excel文件 ")
    public String toExcel(@ApiParam("路径") @PathVariable String url){ return auas.exportExcel(url); }
}
